package com.course.app.biz;

import com.course.app.api.data.CourseDTO;
import com.course.app.transformer.CourseTransformer;
import com.course.domain.model.AgendaInfo;
import com.course.domain.model.CourseInfo;
import com.course.domain.service.AgendaService;
import com.course.domain.service.CourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by Justin on 2017/5/15.
 */
@Component
public class CourseBiz {

    private final CourseService courseService;
    private final AgendaService agendaService;

    @Autowired
    public CourseBiz(CourseService courseService, AgendaService agendaService) {
        this.courseService = courseService;
        this.agendaService = agendaService;
    }

    public CourseDTO loadCourse(int studentId, int courseId) {
        CourseInfo courseInfo = courseService.loadInfo(courseId);
        AgendaInfo agendaInfo = agendaService.loadInfo(studentId, courseId);
        return CourseTransformer.toDTO(courseInfo, agendaInfo.getBeginDate());
    }
}
